/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import Taro, { Component } from '@tarojs/taro'

// project
import { CPage, CContent, CHeader, CFooter, CFloat, CAround, CBetween, CCenter, CRow, CWrap, CLine, CHand, CItemX, CItemY, CText, CLabel, CSvg, CImage, CButton, CColumn } from '../../../library/comp';
import { Base64, Gen, Time, Zip, Session, Storage, Toast} from '../../../library/func';
import Http from '../../../project/func/http/http'
import "../../../library/style/patch.css"

import Icon from '../../style/icon'

// 引用组件
/******************************************************************************************
 * Export Class
 ******************************************************************************************/

class TabHeader extends Component {

	constructor(props) {
        super(props);
        this.state = {
            active:1,
        }
    }

    /*------------------------------------------------------------------------------------
	 * 自定义方法
	 *-----------------------------------------------------------------------------------*/

    OnChooseOne = ()=>{
        this.setState({
            active:1,
        })
        this.props.onTabone();
    }


    OnChooseTwo = ()=>{
        this.setState({
            active:2,
        })
        this.props.onTabtwo();
    }

	/**
	 * 渲染
	 */
	render() {
        // 渲染
		return (
            <CLine class="f1" h="45" x="center" bg="#C3AB7A">
                <CBetween bg="white">
                    <CHand class="f03" h="45" x="left" y="center"  onClick={ this.props.onSearch }>
                        <CSvg ml="10" w='26' h='26' color='#838383' icon={Icon.search}></CSvg>
                    </CHand>
                    <CHand class="f03" y="center" h="45" x="center" onClick={ this.OnChooseOne }>
                        { this.state.active == "1" ?
                        <CText size="15" mt="2" bb="#d7c361 6 solid" color='#2e2e2e' pb='4'>动态</CText>
                        :
                        <CText size="15" color="#8b8b8b" pb='4'>动态</CText>
                        }
                    </CHand>
                    <CHand class="f03" y="center" h="45" x="center" onClick={ this.OnChooseTwo }>
                        { this.state.active == "2" ?
                        <CText size="15" mt="2" bb="#d7c361 6 solid" color='#2e2e2e' pb='4'>活动</CText>
                        :
                        <CText size="15" color="#8b8b8b" pb='4'>活动</CText>
                        }
                        { this.props.dian ?
                        <view style="width:13rpx; height:13rpx; border-radius:50px; background:#d3000c; margin-top:-25rpx; margin-left:8rpx;"></view>
                        :
                        <view style="width:13rpx; height:13rpx; border-radius:50px; background:#fff; margin-top:-25rpx; margin-left:8rpx;"></view>
                        }
                    </CHand>
                    
                    {
                        this.props.is_master ?
                        <CHand class="f03" h="45" y="center" x="right"  onClick={ this.props.onAdd }>
                            <CSvg mr="10" w='16' h='16' color='#707070'  icon={Icon.addtwo}></CSvg>
                        </CHand>
                        :
                        <CHand class="f03" h="45" y="center" x="right"  onClick={ this.props.onAdd }>
                        </CHand>
                    }

                </CBetween>
            </CLine>



		);
	}

};